<?php if (!defined('BASEPATH'))    exit('No direct script access allowed');

class m_admin extends CI_Model{
    public function __construct() {
        parent::__construct();
    }
    
    function login_check($param) {
        $sql = "SELECT * FROM admin WHERE username_admin = ? AND password_admin = ?";
        $query = $this->db->query($sql, $param);
        if($query->num_rows() > 0){
            $result = $query->row_array();
            return $result;
        }else{
            return false;
        }
    }
    
    function setlast_log_adm($param){
        $sql = "UPDATE admin SET last_log = now()WHERE username_admin = ?";
        $query = $this->db->query($sql, $param);
    }

    function update_admin($param){
        $sql = "UPDATE admin SET username_admin=?, password_admin=? WHERE id_admin = ?";
        $query = $this->db->query($sql, $param);
        if($query){
            return true;
        }else{
            return false;
        }
    }
}
